import {
	defineConfig,
	loadEnv
} from 'vite'
import vue from '@vitejs/plugin-vue'
import {
	resolve
} from 'path'
export default defineConfig(({
	command,
	mode
}) => {
	const env = loadEnv(mode, process.cwd(), '')
	return {
		base: './',
		resolve: {
			alias: {
				"@": resolve(__dirname, "src"),
				"comp": resolve(__dirname, "src/components"),
				"/img": "./src/assets",
			}
		},
		server: {
			host: '0.0.0.0',
			port: env.VITE_RUN_PORT,
			proxy: {
				"/xhTranslateApi": {
					target: env.VITE_BASE_URL,
					changeOrigin: true,
					rewrite: (path) => path.replace(/^\/xhTranslateApi/, ""),
				},
			},
		},
		build: {
			terserOptions: {
				compress: {
					//生产环境时移除console
					drop_console: true,
					drop_debugger: true,
				},
			},
		},
		plugins: [vue()]
	}
})
